package edu.gatech.gui;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

import edu.gatech.datastorage.DoctorsOrders;
import edu.gatech.datastorage.Invoice;
import edu.gatech.datastorage.Prescription;
import edu.gatech.presenters.DoctorPresenter;
import edu.gatech.userclasses.Doctor;
import edu.gatech.userclasses.Patient;
import java.awt.Color;
import javax.swing.JLabel;

public class DoctorPanel {
	private static JButton btnAddOrders;
	private static JTextField txtPatientName;
	private static JButton btnViewReports;
	private JTextField txtPatientName_1;
	private JButton btnSearch;
	private Doctor currentDoctor;
	private JPanel panel_1;
	private JPanel panel_2;
	private DoctorPresenter presenter;
	private JLabel lblPatientName;
	public DoctorPanel(Doctor curDoctor){
		currentDoctor = curDoctor;
		JFrame doctor = new JFrame("Doctor Panel");
		doctor.getContentPane().setLayout(null);
		
		txtPatientName = new JTextField();
		txtPatientName.setFont(new Font("Arial", Font.PLAIN, 10));
		txtPatientName.setBounds(246, 195, 182, 21);
		doctor.getContentPane().add(txtPatientName);
		txtPatientName.setColumns(10);
		
		btnViewReports = new JButton("View Reports");
		btnViewReports.setFont(new Font("Arial", Font.PLAIN, 10));
		btnViewReports.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				presenter = new DoctorPresenter(currentDoctor);
				presenter.viewReports(txtPatientName.getText());
			}
		});
		btnViewReports.setBounds(171, 227, 116, 21);
		doctor.getContentPane().add(btnViewReports);
		
		btnAddOrders = new JButton("Add Doctors Orders");
		btnAddOrders.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				presenter = new DoctorPresenter(currentDoctor);
				presenter.addOrders(txtPatientName.getText());
//				boolean selected = chckbxFollowUp.isSelected();
//				presenter.addOrders(txtMedicine.getText(), txtFrequency.getText(), txtLabWork.getText(), 
//						txtFollowUp.getText(), txtOther.getText(), txtPatientName_2.getText(), selected);
				
			}
		});
		btnAddOrders.setBounds(297, 227, 132, 21);
		doctor.getContentPane().add(btnAddOrders);
		btnAddOrders.setFont(new Font("Arial", Font.PLAIN, 10));
		
		panel_1 = new JPanel();
		panel_1.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		panel_1.setBounds(386, 11, 188, 34);
		doctor.getContentPane().add(panel_1);
		
		txtPatientName_1 = new JTextField();
		panel_1.add(txtPatientName_1);
		txtPatientName_1.setFont(new Font("Arial", Font.PLAIN, 10));
		txtPatientName_1.setText("Patient Name");
		txtPatientName_1.setColumns(10);
		
		btnSearch = new JButton("Search");
		btnSearch.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
					presenter = new DoctorPresenter(currentDoctor);
					presenter.search(txtPatientName_1.getText());
			}
		});
		panel_1.add(btnSearch);
		btnSearch.setFont(new Font("Arial", Font.PLAIN, 10));
		
		lblPatientName = new JLabel("Patient Name:");
		lblPatientName.setFont(new Font("Arial", Font.PLAIN, 10));
		lblPatientName.setBounds(171, 198, 78, 14);
		doctor.getContentPane().add(lblPatientName);
		
		panel_2 = new JPanel();
		panel_2.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Actions", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(105, 105, 105)));
		panel_2.setBounds(151, 169, 295, 103);
		doctor.getContentPane().add(panel_2);
		
		MenuBar menuBar = new MenuBar(doctor);
        
        doctor.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        doctor.setSize(600,480);
        doctor.setTitle("Doctor Panel");
        doctor.setLocationRelativeTo(null);  
        doctor.setVisible(true);
	}
}
